package com.sword.controller.stock;

import com.sword.constant.MessageConstant;
import com.sword.page.PageResult;
import com.sword.page.QueryPageBean;
import com.sword.pojo.stock.EnterstockDetail;
import com.sword.service.impl.stock.EnterStockDetailServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stock")
public class EnterStockDetailController {
    @Autowired
    private EnterStockDetailServiceImpl enterstockdetailService;

//    @Autowired
//    EnterStockDetailService enterstockdetailService = new EnterStockDetailServiceImpl();

    /*
    查询所有入库明细
     */
    @RequestMapping("/getStockDetail")
    @ResponseBody
    public PageResult queryProduct(@RequestBody QueryPageBean queryPageBean) {
        try {
            return enterstockdetailService.queryEnterStockDetail(queryPageBean);
        } catch (Exception e) {
            e.printStackTrace();
            return new PageResult(500, MessageConstant.QUERY_PRODOCT_FAIL, null, null);
        }
    }
    /*
查询所有数据用于可视化
*/
    @ResponseBody
    @RequestMapping("/getdetail")
    public Map getdetail() {
        List<EnterstockDetail> employees = enterstockdetailService.queryAll();
        Map map = new HashMap();
        map.put("code", 0);
        map.put("data",employees);
        return map;
    }
}
